﻿using System.IO;
using System.Web;

namespace SpiderMaster.AspNet.TradingSystem
{
    public sealed partial class MemberManagement
    {
        /// <summary> Gets the instance. (in Safe Mode or Client Initializer)
        /// </summary>
        /// <returns></returns>
        public static MemberManagement GetInstance() // TODO: ABOVE
        {
            if (_Instance.IsNull())
            {
                _Instance = new MemberManagement();

                string dataFilePath = HttpContext.Current.Server.MapPath(_Instance.GetXmlFullVirtualFilePath());

                if (File.Exists(dataFilePath))
                    _Instance.LoadData();
                else if (_Instance.CheckEnvironmentSetup()) // Should be First Use
                    _Instance.Reset(); // by Reseting we are re-creating the esentials.
                else _Instance.SaveData(); // We should only do this first ever run..
            }
            return _Instance;
        }
    }
}